package com.huan.iteye.service.impl;

import com.huan.iteye.domain.IteyeBlogView;
import com.huan.iteye.repository.IteyeBlogViewRepository;
import com.huan.iteye.service.IteyeBlogViewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 博客访问量 service impl
 *
 * @author huan.fu
 * @date 2018/9/13 - 10:28
 */
@Service
public class IteyeBlogViewServiceImpl implements IteyeBlogViewService {

	@Autowired
	private IteyeBlogViewRepository blogViewRepository;

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void batchInsertBlogView(List<IteyeBlogView> blogViews) {
		if (null != blogViews && !blogViews.isEmpty()) {
			blogViewRepository.save(blogViews);
		}
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void deleteBlogView(String workDate) {
		blogViewRepository.deleteByWorkDate(workDate);
	}
}
